package cc.laop.controller.system;

import cc.laop.business.system.UserBusiness;
import cc.laop.entity.Page;
import cc.laop.entity.system.User;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("admin/system/user")
public class UserController {

    @Autowired
    private UserBusiness userBusiness;

    @RequestMapping("list.do")
    @ResponseBody
    public Map<String, Object> list(User user, Page page) {
        Map<String, Object> map = new HashMap<String, Object>();
        PageInfo<User> pager = userBusiness.selectByPage(user, page);
        map.put("pager", pager);
        return map;
    }

    @RequestMapping("editRole.do")
    @ResponseBody
    public Map<String, Object> editRole(int userid, String roleids) {
        Map<String, Object> map = new HashMap<String, Object>();
        userBusiness.updateRole(userid, roleids);
        map.put("result", "1");
        return map;
    }
}
